/************************************************************************
 * The code is owned by mainframer.cn and Shang Tao
 * Without aproval of mainframer.cn and Shang Tao, removing the copyright
 * infomation is regarded as invassion of proprietary copyright
 ***********************************************************************/
package com.mr.qa.dao.impl;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.mr.qa.GlobalConfigs;
import com.mr.qa.bo.Question;
import com.mr.qa.bo.QuestionCategory;
import com.mr.qa.exception.QaException;

/**
 * Data access object (DAO) for domain model class Question.
 * @see .Question
 * @author 
 */
public class QuestionDAO extends BaseHibernateDAO
{
    private static final Log log = LogFactory.getLog(QuestionDAO.class);
    //property constants
    private static final String TITLE = "title";
    /**
     * 
     * @param queryString
     * @return
     */
    private String filterQuestionsByUserType(String queryString)
    {
        String userType = this.getUserType();
        String hideCategoryWhere = "";
        if("0".equals(userType) || userType == null || userType.trim().length() == 0)
        {
            hideCategoryWhere = "model.mrIaskCategory.state != '1'";
        }
        if(hideCategoryWhere.length() == 0)
        {
            return queryString;
        }
        else
        {
            if(queryString.indexOf("where") > 0)
            {
                queryString = queryString.replaceFirst("where","where "+hideCategoryWhere+" and"); 
            }
            else
            {
                if(queryString.indexOf("order by") > 0)
                {
                    queryString = queryString.replaceFirst("order by","where "+hideCategoryWhere+" order by"); 
                }
                else
                {
                    queryString = queryString+" where "+hideCategoryWhere;
                }
            }
        }
        //System.out.println("filtered queryString:"+queryString);
        return queryString;
    }
    
    public void save(Question transientInstance)
    {
        //log.debug("saving Question instance");
        try
        {
            getSession().save(transientInstance);
            //log.debug("save successful");
        }
        catch(RuntimeException re)
        {
            //log.error("save failed", re);
            throw re;
        }
    }
    
    public void delete(Question persistentInstance)
    {
        //log.debug("deleting Question instance");
        try
        {
            getSession().delete(persistentInstance);
            //log.debug("delete successful");
        }
        catch(RuntimeException re)
        {
            //log.error("delete failed", re);
            throw re;
        }
    }
	
    public void update(Question transientInstance) 
    {
        //log.debug("update Question instance");
        try
        {
            getSession().update(transientInstance);
            log.debug("update successful");
        }
        catch (RuntimeException re)
        {
            //log.error("update failed", re);
            throw re;
        }
    }
    
    public Question findById( java.lang.Integer id) 
    {
        //log.debug("getting Question instance with id: " + id);
        try
        {
            Question instance = (Question) getSession()
                    .get("com.mr.qa.bo.Question", id);
            return instance;
        }
        catch(RuntimeException re)
        {
            //log.error("get failed", re);
            throw re;
        }
    }
    
    public List findAll()
    {
        return findAll(null);
    }

    /**
     * return the question without isTop=true
     * is used for the latest questions
     * @return
     */
    public List findAllWithoutTop()
    {
        return findAll();
    }
    

    public List findQuestionsByTitle(String title, Integer categoryType) throws QaException
    {
        try
        {
            String queryStr;
            queryStr = "select model from Question as model where model.title like ? and model.state != ? and model.mrIaskCategory.onlyForAdmin = 'N'";
            HashMap parameters = new HashMap();
            parameters.put(0,"%"+title+"%");
            parameters.put(1,"4");
            if(categoryType != null){
            	queryStr += " and model.mrIaskCategory.type = ?";
            	parameters.put(2, categoryType);
            }
            queryStr += " order by model.changeDate desc";
            return this.getQueryList(queryStr,parameters);
        }
        catch(Exception e)
        {
            throw new QaException(e);
        }
    }

    public int countQuestionsByTitle(String title, Integer categoryType)
    {
        String queryStr;
        queryStr = "select count(*) from Question as model where model.title like ? and model.state != ? and model.mrIaskCategory.onlyForAdmin = 'N'";
        HashMap paratmers = new HashMap();
        paratmers.put(0,"%"+title+"%");
        paratmers.put(1,"4");
        if(categoryType != null){
        	queryStr += " and model.mrIaskCategory.type = ?";
        	paratmers.put(2, categoryType);
        }
        return this.countQuery(queryStr,paratmers);
    }
    public int countAll()
    {
        return countAll(null);
    }
    
    public int countByType(Integer categoryType)
    {
        return countAll("model.mrIaskCategory.type = " + categoryType);
    }
    
    public int countRecommendedAll(Integer categoryType)
    {
        return countAll("(model.state = '1' or model.state = '5') and model.mrIaskCategory.type=" + categoryType);
    }
    public int countComplicatedAll(Integer categoryType)
    {
        int count = countAll("(model.state = '2' or model.state = '5') and model.mrIaskCategory.type=" + categoryType);
        //log.info("count="+count);
        return count;
    }
    public int countHotAll(Integer categoryType)
    {
        return countAll("model.mrIaskAnswers.size > "+GlobalConfigs.Q_ANSWER_COUNTS+" and model.viewCount > "+GlobalConfigs.Q_VIEW_COUNTS + "and model.mrIaskCategory.type=" + categoryType);
    }
    
    public List findRecommendedAll(){
    	return findRecommendedAll(null);
    }
    
    public List findRecommendedAll(Integer categoryType)
    {
    	if(categoryType == null){
    		return findAll("(model.state = '1' or model.state = '5')");
    	}
        return findAll("(model.state = '1' or model.state = '5') and model.mrIaskCategory.type=" + categoryType);
    }
    
    public List findComplicatedAll(Integer categoryType)
    {
        return findAll("(model.state = '2' or model.state = '5') and model.mrIaskCategory.type=" + categoryType);
    }

    public List findHotAll()
    {
        return findAll("model.mrIaskAnswers.size > "+GlobalConfigs.Q_ANSWER_COUNTS+" and model.viewCount > "+GlobalConfigs.Q_VIEW_COUNTS);
    }
    
    public List findHotAll(Integer categoryType)
    {
    	if(categoryType == null){
    		return findHotAll();
    	}
        return findAll("model.mrIaskAnswers.size > "+GlobalConfigs.Q_ANSWER_COUNTS+" and model.viewCount > "+GlobalConfigs.Q_VIEW_COUNTS + "and model.mrIaskCategory.type=" + categoryType);
    }
    
    /**
     * find all questions without hidden ones
     * @param whereStr
     * @return
     */
    private List findAll(String whereStr) 
    {
        String queryStr = "";        
        try
        {
            if(whereStr == null || whereStr.trim().length() == 0)
            {
                queryStr = "select distinct model from Question as model " +
                "where model.state != '4' and model.mrIaskCategory.onlyForAdmin = 'N' " +
                "order by model.isTop desc,model.changeDate desc";
            }
            else
            {
                queryStr = "select distinct model from Question as model " +
                "where "+whereStr+" and model.state != '4' " +
                "and model.mrIaskCategory.onlyForAdmin = 'N' " +
                "order by model.isTop desc,model.changeDate desc";
            }
            return this.getQueryList(filterQuestionsByUserType(queryStr),null);
        }
        catch(RuntimeException re) 
        {
            log.error("findAll using query:"+queryStr, re);
            throw re;
        }
    }  
    
    private int countAll(String whereStr)
    {
        String queryStr = "";
        if(whereStr == null || whereStr.trim().length() == 0)
        {
            queryStr = filterQuestionsByUserType("select count(*) from Question as model where model.state != '4' and model.mrIaskCategory.onlyForAdmin = 'N' and model.mrIaskCategory != 122 ");
        }
        else
        {
            queryStr = filterQuestionsByUserType("select count(*) from Question as model where "+whereStr+" and model.state != '4' and model.mrIaskCategory.onlyForAdmin = 'N' and model.mrIaskCategory != 122 ");
        }
        return this.countQuery(queryStr,null);
    }


    /**
     * getting the amount number of questions for viewing of other user
     * @param userId
     * @return
     * @throws QaException
     */
    public int countUserQuestions(Integer userId) throws QaException
    {
        try
        {
            String queryString = "select count(*) from Question as model where " +
            "model.mrIaskUser.id = ? and model.state != ? and model.mrIaskCategory.onlyForAdmin = 'N'";
            HashMap parameters = new HashMap();
            parameters.put(0,userId);
            parameters.put(1,"4");
            return this.countQuery(queryString,parameters);
        }
        catch(Exception e)
        {
            throw new QaException(e);
        }
    }
    
    /**
     * getting the amount number of recommeded questions for viewing of other user
     * @param userId
     * @return
     * @throws QaException
     */
    public int countUserRecommendQuestions(Integer userId) throws QaException
    {
        try
        {
            String queryString = "select count(*) from Question as model where " +
            "model.mrIaskUser.id = ? and model.state in (?,?) and model.mrIaskCategory.onlyForAdmin = 'N'";
            HashMap parameters = new HashMap();
            parameters.put(0,userId);
            parameters.put(1,"1");
            parameters.put(2, "5");
            return this.countQuery(queryString,parameters);
        }
        catch(Exception e)
        {
            throw new QaException(e);
        }
    }


    /**
     * getting questions for viewing of other user
     * @param userId
     * @return
     * @throws QaException
     */
    public List findUserQuestions(Integer userId) throws QaException
    {
        try
        {
            String queryString = "from Question as model where model.mrIaskUser.id = ? " +
            "and model.state != ? and model.mrIaskCategory.onlyForAdmin = ? order by model.postDate desc"; 
            HashMap parameters = new HashMap();
            parameters.put(0,userId);
            parameters.put(1,"4");
            parameters.put(2,"N");
            return this.getQueryList(queryString,parameters);            
        }
        catch(Exception e)
        {
            throw new QaException(e);
        }
    }
    /*
     * accessMode:0 viewed by self;1 viewed by others
     */
    public int countMyQuestions(Integer userId)
    {
        try
        {
            String queryString = "select count(*) from Question as model where model." 
                                + "mrIaskUser.id = ?";
            HashMap parameters = new HashMap();
            parameters.put(0,userId);
            return this.countQuery(queryString,parameters);
        }
        catch (RuntimeException re)
        {
            throw re;
        }
    
    }
    /**
     * my center questions 
     * @param userId
     * @return
     */
    public List findMyQuestions(Integer userId)
    {
        return findByProperty("mrIaskUser.id",userId);        
    }


    
    public List findByProperty(String propertyName, Object value) 
    {
        try
        {
            String queryString = "from Question as model where model." 
         						+ propertyName 
                                                        + "= ? order by model.postDate desc";
            HashMap parameters = new HashMap();
            parameters.put(0,value);
            return this.getQueryList(queryString,parameters);
      }
      catch (RuntimeException re) 
      {
         throw re;
      }
    }

	public List findByTitle(Object title) {
		return findByProperty(TITLE, title);
	}
/*	
	public List findByReference(Object reference) {
		return findByProperty(REFERENCE, reference);
	}
	
	public List findByContent(Object content) {
		return findByProperty(CONTENT, content);
	}
	
	public List findByAddition(Object addition) {
		return findByProperty(ADDITION, addition);
	}
	
	public List findByFile(Object file) {
		return findByProperty(FILE, file);
	}
	
	public List findByState(Object state) {
		return findByProperty(STATE, state);
	}
	
	public List findByIsPoll(Object isPoll) {
		return findByProperty(IS_POLL, isPoll);
	}
	
	public List findByIsAnonymous(Object isAnonymous) {
		return findByProperty(IS_ANONYMOUS, isAnonymous);
	}
	
	public List findByViewCount(Object viewCount) {
		return findByProperty(VIEW_COUNT, viewCount);
	}
	
    public Question merge(Question detachedInstance) {
        log.debug("merging Question instance");
        try {
            Question result = (Question) getSession()
                    .merge(detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(Question instance) {
        log.debug("attaching dirty Question instance");
        try {
            getSession().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
    
    public void attachClean(Question instance) {
        log.debug("attaching clean Question instance");
        try {
            getSession().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
*/
    /**
     * 
     * @param questionCategory
     * @return List
     * @throws QaException
     */
    public List getAllQuestionsForAQuestionCategory(QuestionCategory questionCategory) throws QaException
    {
        return getAllQuestionsForAQuestionCategory(questionCategory,null);
    }
    
    public List getAllQuestionsForAQuestionCategoryCities(QuestionCategory questionCategory, Integer city) throws QaException
    {
    	String whereCls = null;
    	if (city != null && city != 0){
    		whereCls = "city.id = " + city;
    	}
        return getAllQuestionsForAQuestionCategory(questionCategory,whereCls);
    }
    
    
    public List getAllRecommendedQuestionsForAQuestionCategory(QuestionCategory questionCategory) throws QaException
    {
        return getAllQuestionsForAQuestionCategory(questionCategory,"(model.state = '1' or model.state = '5')");
    }
    
    public int countAllRecommendedQuestionsForAQuestionCategory(QuestionCategory questionCategory) throws QaException
    {
        return countAllQuestionsForAQuestionCategory(questionCategory,"(model.state = '1' or model.state = '5')");
    }
    
    public List getAllComplicatedQuestionsForAQuestionCategory(QuestionCategory questionCategory) throws QaException
    {
        return getAllQuestionsForAQuestionCategory(questionCategory,"(model.state = '2' or model.state = '5')");
    }
    public int countAllComplicatedQuestionsForAQuestionCategory(QuestionCategory questionCategory) throws QaException
    {
        return countAllQuestionsForAQuestionCategory(questionCategory,"(model.state = '2' or model.state = '5')");
    }
    
    public List getAllHotQuestionsForAQuestionCategory(QuestionCategory questionCategory) throws QaException
    {
        return getAllQuestionsForAQuestionCategory(questionCategory,"model.mrIaskAnswers.size > "+GlobalConfigs.Q_ANSWER_COUNTS+" and model.viewCount > "+GlobalConfigs.Q_VIEW_COUNTS);
    }
    public int countAllHotQuestionsForAQuestionCategory(QuestionCategory questionCategory) throws QaException
    {
        return countAllQuestionsForAQuestionCategory(questionCategory,"model.mrIaskAnswers.size > "+GlobalConfigs.Q_ANSWER_COUNTS+" and model.viewCount > "+GlobalConfigs.Q_VIEW_COUNTS);
    }
    
    //2008.9.17
    public List getAllNew()
    {
        //get 20 
        //if not enough, go on to search
        return null;
    }
    
    
    //2008.9.17
    
    
    
    private String makeCountQueryStringForQuestionCategory(QuestionCategory questionCategory,String whereStr) throws QaException
    {
        Integer questionCategoryId = questionCategory.getId();
        if(questionCategoryId == null)throw new QaException("Question Category Id required");
        Integer level = questionCategory.getLevel();
        String queryString = "";
        if(whereStr == null || whereStr.length() == 0)
            queryString = "select count(*) from Question as model where model.state != '4' and model.mrIaskCategory.id in ";
        else
            queryString = "select count(*) from Question as model where "+whereStr+" and"+" model.state != '4' and model.mrIaskCategory.id in ";
        String whereString = "";
        if(level.intValue() == 1)
        {
            Collection level2QuestionCategories = questionCategory.getMrIaskCategories();
            if(level2QuestionCategories.size() == 0)//no level 2
            {
                whereString = "'"+questionCategory.getId()+"'";
            }
            else//level 2 exist
            {
                whereString = "'"+questionCategory.getId()+"'";//new
                Iterator level2Iterator = level2QuestionCategories.iterator();
                QuestionCategory level2QuestionCategory = null;
                QuestionCategory level3QuestionCategory = null;
                Iterator level3Iterator = null;
                Collection level3QuestionCategories = null;
                while(level2Iterator.hasNext())
                {
                    level2QuestionCategory = (QuestionCategory)level2Iterator.next();
                    level3QuestionCategories = level2QuestionCategory.getMrIaskCategories();
                    if(level3QuestionCategories.size() > 0)//level 2 has level 3
                    {
                        whereString += ",'"+level2QuestionCategory.getId()+"'";//new
                        level3Iterator = level3QuestionCategories.iterator();
                        while(level3Iterator.hasNext())
                        {
                            level3QuestionCategory = (QuestionCategory)level3Iterator.next();
                            //or cause
                            if(whereString.length() == 0)
                                whereString = "'"+level3QuestionCategory.getId()+"'";
                            else
                                whereString = whereString+",'"+level3QuestionCategory.getId()+"'";
                        }
                    }
                    else//leve2 has no level 3
                    {
                        //or cause
                         if(whereString.length() == 0)
                             whereString = "'"+level2QuestionCategory.getId()+"'";
                         else
                             whereString += ",'"+level2QuestionCategory.getId()+"'";
                        
                    }
                }
            }
        }
        else if(level.intValue() == 2)
        {
            Collection level3QuestionCategories = questionCategory.getMrIaskCategories();
            if(level3QuestionCategories.size() > 0)
            {
                whereString = "'"+questionCategory.getId()+"'";//new
                Iterator level3Iterator = level3QuestionCategories.iterator();
                QuestionCategory level3QuestionCategory = null;
                while(level3Iterator.hasNext())
                {
                    level3QuestionCategory = (QuestionCategory)level3Iterator.next();
                    //or cause
                     if(whereString.length() == 0)
                         whereString = "'"+level3QuestionCategory.getId()+"'";
                     else
                         whereString += ",'"+level3QuestionCategory.getId()+"'";
                    
                }
            }
            else
            {
                whereString = "'"+questionCategory.getId()+"'";
            }
        }
        else if(level.intValue() == 3)
        {
             whereString = "'"+questionCategory.getId()+"'";
        }
        whereString = "("+whereString+")";
        queryString = queryString+whereString;
        return queryString;        
    }
    
    private String makeQueryStringForQuestionCategory(QuestionCategory questionCategory,String whereStr) throws QaException
    {
        Integer questionCategoryId = questionCategory.getId();
        if(questionCategoryId == null)throw new QaException("Question Category Id required");
        Integer level = questionCategory.getLevel();
        String queryString = "";
        if(whereStr == null || whereStr.length() == 0)
            queryString = "select distinct model from Question as model " +
            "where model.state != '4' and model.mrIaskCategory.id in ";
        else if(whereStr.contains("city"))
        	queryString = "select distinct model from Question as model inner join fetch model.cities city " +
            "where "+whereStr+" and"+" model.state != '4' and model.mrIaskCategory.id in ";
        else
            queryString = "select distinct model from Question as model " +
            "where "+whereStr+" and"+" model.state != '4' and model.mrIaskCategory.id in ";
        String whereString = "";
        if(level.intValue() == 1)
        {
            Collection level2QuestionCategories = questionCategory.getMrIaskCategories();
            if(level2QuestionCategories.size() == 0)//no level 2
            {
                whereString = "'"+questionCategory.getId()+"'";
            }
            else//level 2 exist
            {
                whereString = "'"+questionCategory.getId()+"'";//new
                Iterator level2Iterator = level2QuestionCategories.iterator();
                QuestionCategory level2QuestionCategory = null;
                QuestionCategory level3QuestionCategory = null;
                Iterator level3Iterator = null;
                Collection level3QuestionCategories = null;
                while(level2Iterator.hasNext())
                {
                    level2QuestionCategory = (QuestionCategory)level2Iterator.next();
                    level3QuestionCategories = level2QuestionCategory.getMrIaskCategories();
                    if(level3QuestionCategories.size() > 0)//level 2 has level 3
                    {
                        whereString += ",'"+level2QuestionCategory.getId()+"'";//new
                        level3Iterator = level3QuestionCategories.iterator();
                        while(level3Iterator.hasNext())
                        {
                            level3QuestionCategory = (QuestionCategory)level3Iterator.next();
                            //or cause
                            if(whereString.length() == 0)
                                whereString = "'"+level3QuestionCategory.getId()+"'";
                            else
                                whereString = whereString+",'"+level3QuestionCategory.getId()+"'";
                        }
                    }
                    else//leve2 has no level 3
                    {
                        //or cause
                    	if(level2QuestionCategory.getId() != 122 && questionCategory.getId() != 122){ //added
                         if(whereString.length() == 0)
                             whereString = "'"+level2QuestionCategory.getId()+"'";
                         else
                             whereString += ",'"+level2QuestionCategory.getId()+"'";
                    	}
                        
                    }
                }
            }
        }
        else if(level.intValue() == 2)
        {
            Collection level3QuestionCategories = questionCategory.getMrIaskCategories();
            if(level3QuestionCategories.size() > 0)
            {
                whereString = "'"+questionCategory.getId()+"'";//new
                Iterator level3Iterator = level3QuestionCategories.iterator();
                QuestionCategory level3QuestionCategory = null;
                while(level3Iterator.hasNext())
                {
                    level3QuestionCategory = (QuestionCategory)level3Iterator.next();
                    //or cause
                     if(whereString.length() == 0)
                         whereString = "'"+level3QuestionCategory.getId()+"'";
                     else
                         whereString += ",'"+level3QuestionCategory.getId()+"'";
                    }
            }
            else
            {
                whereString = "'"+questionCategory.getId()+"'";
            }
        }
        else if(level.intValue() == 3)
        {
        		whereString = "'"+questionCategory.getId()+"'";
        }
        whereString = "("+whereString+")";
        //add order model.isExpired 2008.8.31
        //isTop --->isSecondaryTop 2008.10.19
        queryString = queryString+whereString+" order by model.isSecondaryTop desc,model.isExpired,model.changeDate desc";
        //log.info("queryString="+queryString);
        return queryString;        
    }
    
    public int countAllQuestionsForAQuestionCategory(QuestionCategory questionCategory) throws QaException
    {
        return countAllQuestionsForAQuestionCategory(questionCategory,null);
    }
    
    private int countAllQuestionsForAQuestionCategory(QuestionCategory questionCategory,String whereStr) throws QaException
    {
        String queryString = makeCountQueryStringForQuestionCategory(questionCategory,whereStr);
        return this.countQuery(queryString,null);
        /*
        Query queryObject = getSession().createQuery(queryString);
        long longCount = (Long)queryObject.uniqueResult();
        return new Integer(""+longCount);
        */
    }
    
    public List getAllQuestionsForAQuestionCategoryType(Integer typeId,String whereStr) throws QaException
    {
    	String queryString = null;
    	if(whereStr == null || whereStr.length() == 0)
            queryString = "select distinct model from Question as model " +
            "where model.state != '4' and model.mrIaskCategory.type = ";
        else
            queryString = "select distinct model from Question as model " +
            "where "+whereStr+" and"+" model.state != '4' and model.mrIaskCategory.type = ";
    	queryString += typeId + " order by model.isSecondaryTop desc,model.isExpired,model.changeDate desc";
        return this.getQueryList(queryString,null);
        /*
        Query queryObject = getSession().createQuery(queryString);
        long longCount = (Long)queryObject.uniqueResult();
        return new Integer(""+longCount);
        */
    }
    
    /**
     * 2007-5-6 TOM added
     */
    private List getAllQuestionsForAQuestionCategory(QuestionCategory questionCategory,String whereStr) throws QaException
    {
        String queryString = makeQueryStringForQuestionCategory(questionCategory,whereStr);
        return this.getQueryList(queryString,null);
    }
    
    /*public List findByCategoryType(Integer categoryType){
    	String queryString = "select distinct model from Question as model " +
        "where model.state != '4' and model.mrIaskCategory.type = ?" +
        "and model.mrIaskCategory.onlyForAdmin = 'N' " + 
        "order by model.isTop desc,model.changeDate desc";
    	HashMap map = new HashMap();
    	map.put(0, categoryType);
    	return this.getQueryList(queryString, map);
    }*/
    
    public List findByCategoryType(Integer categoryType, Integer cityId) {
		String queryString = "select distinct model from Question as model ";
		if (cityId != null){
			queryString += "inner join fetch model.cities city ";
		}
		queryString += "where model.state != '4' and model.mrIaskCategory.type = ? "
				+ "and model.mrIaskCategory.onlyForAdmin = 'N' "
				+ "and model.mrIaskCategory != 122 "; //add to hide in parent category
		if (cityId != null) {
			queryString += "and city.id = ? ";
		}
		queryString += "order by model.isTop desc,model.isExpired,model.changeDate desc";;
		HashMap map = new HashMap();
		map.put(0, categoryType);
		if (cityId != null) {
			map.put(1, cityId);
		}
		return this.getQueryList(filterQuestionsByUserType(queryString), map);
	}
}